<?php
include 'funcs.php';
?>
<form action="" method="post">
<h1>Add your DDL Site</h1><br>
<?php
if (isset($_REQUEST['addssub'])) {
	$addsname = $_REQUEST['addsname'];
	$addsname = htmlentities(addslashes($addsname));
	$addsurl = $_REQUEST['addsurl'];
	$addsurl = cleanurl(strtolower($addsurl),true);
	$addssuburl = $_REQUEST['addssuburl'];
	$addssuburl = cleanurl(strtolower($addssuburl),true);
	$addsemail = $_REQUEST['addsemail'];
	$addsemail = htmlentities(addslashes($addsemail));
	
	if ($addsurl != false && $addssuburl != false && !empty($addsname) && !empty($addsemail)) {
	
		$addssiteexists = mysql_query('select * from gc_das_sites where siteurl LIKE "%'.addslashes($addsurl).'%" OR submiturl LIKE "%'.addslashes($addsurl).'%" ') or die ('Error: ' . mysql_error());
		$addssiteexistsinqueue = mysql_query('select * from gc_das_qsites where siteurl LIKE "%'.addslashes($addsurl).'%" OR submiturl LIKE "%'.addslashes($addsurl).'%" ') or die ('Error: ' . mysql_error());
		
		if (mysql_num_rows($addssiteexists) === 0 && mysql_num_rows($addssiteexistsinqueue) === 0) {
			mysql_query('insert into gc_das_qsites (sitename, siteurl, submiturl, adminemail) VALUES ("'.$addsname.'", "'.$addsurl.'", "'.$addssuburl.'", "'.$addsemail.'")') or die('Error: ' . mysql_error());
			echo 'Your DDL Site has been added into the queue. <br>';
		}
		else
		{
			echo 'That site has already been added. <br>';
		}
	
	}
	else
	{
		echo 'The URLs you have entered are not valid. <br>';
	}
	
	echo '<br><br>';
	
}
?>
Site Name: <input type="" name="addsname" /><br>
Site URL: <input type="" name="addsurl" /><br>
Submit URL: <input type="" name="addssuburl" /><br>
Admin Email: <input type="" name="addsemail" /><br>
<input type="submit" name="addssub" />
</form>
<br>
<form action="" method="post">
<h1>Submit Downloads</h1>
<?php
$getsquery = mysql_query('select * from gc_das_sites order by status DESC') or die('Error: ' . mysql_error());
if (mysql_num_rows($getsquery) != 0) {
	while($ssinfo = mysql_fetch_assoc($getsquery)) {
		if ($ssinfo['status'] == 2) {
			echo '<input type="checkbox" name="aasites[]" value="'.$ssinfo['id'].'" checked="checked" /> <a href="http://anonym.to/?http://'.$ssinfo['siteurl'].'">'.$ssinfo['sitename'].'</a><br>'."\r\n";
		}
		elseif ($ssinfo['status'] == 1) {
			echo '<input type="checkbox" name="aasites[]" value="'.$ssinfo['id'].'" checked="checked" /> '.$ssinfo['sitename'].'<br>'."\r\n";
		}
		else
		{
			echo '<input type="checkbox" name="aasites[]" value="'.$ssinfo['id'].'" /> http://'.$ssinfo['submiturl'].'<br>'."\r\n";
		}
	}
}

echo '<br><br>Download Title - Download URL - Download Category<br>';

for ($i=0;$i<=9;$i++) {
	echo '<input type="text" name="title[]" value="" /> <input type="text" name="url[]" value="" /> <select name="type[]">'."\r\n";
	echo '<option value="" selected>Select</option>'."\r\n";
	foreach ($categories as $cattag => $catname) {
		echo '<option value="'. $cattag .'">'. $catname .'</option>'."\r\n";
	}
	echo '</select><br>'."\r\n";
}
?>
<br><br>
<input type="text" name="sname" /> <input type="text" name="surl" /> <input type="text" name="email" />
<br><br>
<input type="submit" name="submit" value="Submit" />
</form>
<br>
<br>
<?php
flush();

if (isset($_REQUEST['submit'])) {
	if (isset($_REQUEST['aasites'])) {
		$subsitesarray = $_REQUEST['aasites'];
		foreach ($subsitesarray as $sitenameorurl => $subsiteid) {
			ob_start();
			$subsiteinfo = mysql_query('select * from gc_das_sites where id="'.$subsiteid.'"') or die('Error: '.mysql_error());
			if (mysql_num_rows($subsiteinfo) != 0) {
				$subsiteinfo = mysql_fetch_assoc($subsiteinfo) or die('Error: '. mysql_error());
				submittosite($subspostme, 'http://'.$subsiteinfo['submiturl']);
					if ($subsiteinfo['status'] == 2) {
						echo '<a href="http://'.$subsiteinfo['siteurl'].'"><span style="color: #F00;background-color:#000;">'.$subsiteinfo['sitename'].' <<< Click ME!</span></a><br><br>';
					}
					elseif ($subsiteinfo['status'] == 1)
					{
						echo '<span style="color: #F00;background-color:#000;">http://'.$subsiteinfo['sitename'].'</span><br><br>';
					}
					else
					{
						echo '<span style="color: #FFF;background-color:#000;">http://'.$subsiteinfo['siteurl'].'</span><br><br>';
					}
					flush();
				}
			
			}

	}
}
?>